package com.axjc.gqzr.mapper;

import com.axjc.gqzr.domain.SysToken;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Optional;

/**
 * @author 大道至简
 * @description 针对表【sys_token】的数据库操作Mapper
 * @createDate 2024-09-16 04:16:00
 * @Entity com.axjc.gqzr.domain.SysToken
 */
public interface SysTokenMapper extends BaseMapper<SysToken> {

    @Select("select * from sys_token where user_id= #{id}")
    List<SysToken> findAllValidTokenByUser(long id);

    @Select("select * from sys_token where token= #{token}")
    Optional<SysToken> findByToken(String token);

    @Insert("insert into sys_token (id, token, tokenType, revoked, expired, user_id) values (#{id}, #{token}, #{tokenType}, #{revoked}, #{expired}, #{user_id});")
    void save(SysToken storedToken);
}




